package com.hippo.client.controller.springdoc.model;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * @ClassName JsonResult
 * @Description TODO 演示json结构的响应类
 * @Author tangxl
 * @create 2023-03-28 09:37
 **/
@Data
@Schema(description = "json结构的响应")
public class JsonResult<T> {
    @Schema(description = "状态码", example = "200")
    private Integer code;
    @Schema(description = "状态码对应的信息", example = "请求成功")
    private String message;
    @Schema(description = "给前端返回的 json 格式的内容")
    private T content;
    // 省略部分内容

    public static <T> JsonResult<T> success(T content) {
        JsonResult<T> result = new JsonResult<>();
        result.setCode(200);
        result.setMessage("请求成功");
        result.setContent(content);
        return result;
    }
}
